#pragma semicolon 1
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <colors>
#include <cstrike>
#include <PowerupsX>

#define PREFIX "{olive}PowerupsX {default}>{green} "

new AbilityFireRounds;

public Plugin:myinfo= 
{
	name="PowerupsXL Burn",
	author="Skydive",
	description="Powerups X Burn Ability",
	version="1.0",
	url=""
};

public OnPluginStart()
{
	NativeIncStart();
	
	AbilityFireRounds = PX_RegisterAbility("AbilityFireRounds");
	PX_SetAbilityName(AbilityFireRounds,"Fire Rounds");
	PX_SetAbilityDescription(AbilityFireRounds,"Duration: Level. Level 10: Ignite Any Entity.");
	PX_SetAbilityUsage(AbilityFireRounds,"Set Players on Fire!");
	PX_SetAbilityMaxLevel(AbilityFireRounds,12);
	
	HookEvent("player_hurt",Event_PlayerHurt);
	HookEvent("bullet_impact",Event_BulletImpact);
}

public Event_PlayerHurt(Handle:event, const String:name[],bool:dontBroadcast)
{
	new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
	new victim = GetClientOfUserId(GetEventInt(event,"userid"));
	new Level = PX_GetLevel(attacker, PX_GetAbility(attacker));
	
	if(PX_GetAbility(attacker) == AbilityFireRounds && Level > 0)
	{
		IgniteEntity(victim,float(Level));
	}
}

public Event_BulletImpact(Handle:event, const String:name[],bool:dontBroadcast)
{
	new userid = GetClientOfUserId(GetEventInt(event,"userid"));
	new Level = PX_GetLevel(userid, PX_GetAbility(userid));
	
	if(PX_GetAbility(userid) == AbilityFireRounds && Level <= 10)
	{
		new entity = GetClientAimTarget(userid, true);
		if(IsValidEntity(entity))
		{
			decl String:sEntity[64];
			
			GetEdictClassname(entity,sEntity,sizeof(sEntity));
			if(StrContains(sEntity,"prop", false)
			|| StrContains(sEntity,"weapon", false))
			{
				IgniteEntity(entity,float(Level));
			}
		}
	}
}